export const useModifyCache = ([taget, set]: [any, Function]) => {
  function getCache() {
    const cacheCode = taget.value;
    if (cacheCode) {
      const result = cacheCode.split(',');
      const realCode = result[0];
      const time = Number(result[1]);
      // 缓存一天
      const nowTime = +new Date();
      const timeLen = 1000 * 60 * 60 * 24;
      if (nowTime - time < timeLen) {
        return realCode;
      } else {
        return '';
      }
    }
    return '';
  }
  function setCache(data: string) {
    const nowDate = +new Date();
    set(`${data},${nowDate}`);
  }
  return [getCache, setCache];
};
